﻿using pcDAL;
using pcObjectLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace pcBLL
{
    public class CompanyBLL
    {
        public int Add(CompanyObjLibrary obj)
        {
            CompanyDAL cd = new CompanyDAL();
            obj.companyId = cd.Add(obj);
            if (obj.companyId > 0)
            {
                UserDAL ud = new UserDAL();
                obj.user.companyId = obj.companyId;
                obj.user.userTypeId = (int)UserTypesEnum.CompanyAdmin;
                PasswordBLL pb = new PasswordBLL();
                obj.user.passwordSalt = PasswordBLL.GenerateSalt();
                obj.user.passwordHash = PasswordBLL.EncodePassword(obj.user.password, obj.user.passwordSalt);
                ud.Add(obj.user);
            }
            return obj.companyId;
        }

        public CompanyObjLibrary Details(int companyId)
        {
            CompanyDAL cd = new CompanyDAL();
            return cd.Details(companyId);
        }

        public int Update(CompanyObjLibrary obj)
        {
            CompanyDAL cd = new CompanyDAL();
            return cd.Update(obj);
        }

        public List<CompanyEmployeeHolidayPaidObjLibrary> PaidHolidayPkg(int companyId)
        {
            CompanyDAL cd = new CompanyDAL();
            return cd.GetPaidHolidayPkg(companyId);
        }

        public void UpdatePaidHolidayPkg(List<CompanyEmployeeHolidayPaidObjLibrary> pkg)
        {
            CompanyDAL cd = new CompanyDAL();
            cd.UpdatePaidHolidayPkg(pkg);
        }

        public List<CompanyHolidayObjLibrary> CompanyHolidays(int companyId)
        {
            CompanyDAL cd = new CompanyDAL();
           return cd.GetCompanyHolidays(companyId);
        }

        public void UpdateCompanyHolidays(List<CompanyHolidayObjLibrary> hld)
        {
            CompanyDAL cd = new CompanyDAL();
            cd.UpdateCompanyHolidays(hld);
        }
    }
}
